package Data;

import java.util.ArrayList;
import java.util.Iterator;


public class UserData {
	private ArrayList<jTeacher> jteacherList;
	private ArrayList<yjTeacher> yjteacherList;
	private ArrayList<rTeacher> rteacherList;
	private ArrayList<Student> studentList;
	
	public UserData () {
		this.jteacherList = new ArrayList<jTeacher>();
		this.yjteacherList = new ArrayList<yjTeacher>();
		this.rteacherList = new ArrayList<rTeacher>();
		this.studentList = new ArrayList<Student>();
	}
	
	public Message registerNewjTeacher(String id, String password, String name) {
		Message result;
		Iterator<jTeacher> iterator = jteacherList.iterator();
		while (iterator.hasNext()) {
			jTeacher someOnejTeacher = iterator.next();
			if (id.equals(someOnejTeacher.getID())) {
				result = Message.REGISTER_FAIL;
				return result;
			}
		}
		jTeacher jteacher = new jTeacher(id, name, password);
		jteacherList.add(jteacher);
		result = Message.REGISTER_SUCCESS;
		return result;
	}
	
	public Message registerNewyjTeacher(String id, String password, String name,String department) {
		Message result;
		Iterator<yjTeacher> iterator = yjteacherList.iterator();
		while (iterator.hasNext()) {
			yjTeacher someOneyjTeacher = iterator.next();
			if (id.equals(someOneyjTeacher.getID())) {
				result = Message.REGISTER_FAIL;
				return result;
			}
		}
		yjTeacher yjteacher = new yjTeacher(id, name, password,department);
		yjteacherList.add(yjteacher);
		result = Message.REGISTER_SUCCESS;
		return result;
	}
	
	public Message registerNewrTeacher(String id, String password, String name) {
		Message result;
		Iterator<rTeacher> iterator = rteacherList.iterator();
		while (iterator.hasNext()) {
			rTeacher someOnerTeacher = iterator.next();
			if (id.equals(someOnerTeacher.getID())) {
				result = Message.REGISTER_FAIL;
				return result;
			}
		}
		rTeacher rteacher = new rTeacher(id, name, password);
		rteacherList.add(rteacher);
		result = Message.REGISTER_SUCCESS;
		return result;
	}

	public Message registerNewStudent(String id, String password, String name) {
		Message result;
		Iterator<Student> iterator = studentList.iterator();
		while (iterator.hasNext()) {
			Student someOneStudent = iterator.next();
			if (id.equals(someOneStudent.getID())) {
				result = Message.REGISTER_FAIL;
				return result;
			}
		}
		Student student = new Student(id, name, password);
		studentList.add(student);
		result = Message.REGISTER_SUCCESS;
		return result;

	}

	public void deletejTeacher(jTeacher jteacher) {
		jteacherList.remove(jteacher);
	}
	
	public void deleteyjTeacher(yjTeacher yjteacher) {
		yjteacherList.remove(yjteacher);
	}
	
	public void deleterTeacher(rTeacher rteacher) {
		rteacherList.remove(rteacher);
	}

	public void deleteStudent(Student student) {
		studentList.remove(student);

	}

	public ArrayList<jTeacher> getjTeacherList() {
		return jteacherList;
	}
	
	public ArrayList<yjTeacher> getyjTeacherList() {
		return yjteacherList;
	}
	
	public ArrayList<rTeacher> getrTeacherList() {
		return rteacherList;
	}

	public ArrayList<Student> getStudentList() {
		return studentList;
	}


}
